package com.shiqu.sqappupdate

import android.graphics.Color
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import com.azhon.appupdate.manager.DownloadManager

class MainActivity : AppCompatActivity() {

    private val url = "http://s.duapps.com/apks/own/ESFileExplorer-cn.apk"
    private val apkName = "appupdate.apk"
    private var manager: DownloadManager? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        findViewById<Button>(R.id.btnUpdate).setOnClickListener {
            startUpdate()
        }
    }


    private fun startUpdate() {
        manager = DownloadManager.Builder(this).run {
            apkUrl(url)
            apkName(apkName)
            smallIcon(R.mipmap.ic_launcher)
            showNewerToast(true)
            apkVersionCode(2)
            apkVersionName("v4.2.1")
            apkSize("7.7MB")
//            apkDescription(getString(R.string.dialog_msg))
            enableLog(true)
            jumpInstallPage(true)
            dialogButtonTextColor(Color.WHITE)
            showNotification(true)
            showBgdToast(false)
            forcedUpgrade(false)
//            onDownloadListener(listenerAdapter)
//            apkMD5("DC501F04BBAA458C9DC33008EFED5E7F")
//            httpManager()
//            dialogImage(R.drawable.ic_dialog)
//            dialogButtonColor(Color.parseColor("#E743DA"))
//            dialogProgressBarColor(Color.parseColor("#E743DA"))
//            notificationChannel()
//            notifyId(1011)
//            onButtonClickListener()
            build()
        }
        manager?.download()
    }

}